package com.gensdai.leliang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gensdai.leliang.R;
import com.gensdai.leliang.entity.User;

import java.util.List;

/**
 * Created by Administrator on 2017/6/2.
 */

public class Invite_friend_deal_adapter extends BaseAdapter {

    Context mContext;
    List<User> list;
    Honder honder;

    public Invite_friend_deal_adapter(Context context, List<User> list) {
        mContext = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            honder = new Honder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.invite_friend_deal_adapter_list, null);
            honder.Nickname = (TextView) convertView.findViewById(R.id.nickname);
            honder.GiveMoney = (TextView) convertView.findViewById(R.id.givemoney);
            honder.Get_gold = (TextView) convertView.findViewById(R.id.get_gold);
            honder.Jibie = (TextView) convertView.findViewById(R.id.jibie);
            honder.Money_state = (TextView) convertView.findViewById(R.id.money_state);
            convertView.setTag(honder);
        } else {
            honder = (Honder) convertView.getTag();
        }
        honder.Nickname.setText(list.get(position).getTotalConsumption());
        honder.GiveMoney.setText(list.get(position).getRewardRatio());
        honder.Jibie.setText(list.get(position).getNickName());
        honder.Get_gold.setText(list.get(position).getRewardAmount());
        honder.Money_state.setText(list.get(position).getRecommendNumber());

        return convertView;
    }

    class Honder {

        TextView Jibie; // 昵称
        TextView Nickname; //  消费金额
        TextView GiveMoney; // 奖金比例
        TextView Get_gold; // 奖励金额
        TextView Money_state; // 邀请人数
    }

}
